1810A - Beautiful Sequence - CodeForces Solution


brute force

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;


/* -------------PBD------------*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
//if less_equal than multiset behaviour ,if greater than descending order arrange


typedef             long double ld;
typedef             long long ll;
typedef             unsigned long long ull;
#define in(x)       ll x;cin>>x
#define in2(x,y)    ll x,y;cin>>x>>y
#define pb          push_back
#define pll         pair<ll,ll>
#define vi          vector<int>
#define mi          map<int,int>
#define mll          map<ll,ll>
#define umi         unordered_map<ll,ll>
#define vll         vector<long long>
#define pii         pair<int,int>
#define pi          3.14159265358979323846
#define test()         ll t; cin >> t; while(t--)
#define loop(i,j,n)    for(ll i=j;i<n;i++)
#define loopr(i, n)    for (int i = n-1; i >= 0; i--)
#define print(x)       cout<<x<<endl;
//#define sort(v)        sort(v.begin(),v.end(),compare);
#define FASTIO         ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 1e9 + 7;
//for giving number to array
 //memset(dp, -1, sizeof(dp));


bool compare(int a,int b){
return a>b;
}
// Operator overloads
// cout << vector<T>
template<typename T> ostream& operator<<(ostream &ostream, const vector<T> &c) {for (auto &it : c) cout << it << " "; return ostream;}
// cin >> vector<T>
template<typename T> istream& operator>>(istream &istream, vector<T> &v) {for (auto &it : v) cin >> it; return istream;}
// descend st
auto cmp = [](int a, int b) { 
return  a>b ;
};
set<int,decltype(cmp)> s1(cmp);
set<ll>::iterator itr;
//bitset<32> bs(5)


/*----------------func-------------*/


template<typename T>
void display(vector<T> v ){
for(auto x : v){
cout<<x<<' ';
}
cout<<endl;
}
/*----------------------Code--------------------------*/


int main() {


#ifndef ONLINE_JUDGE
freopen("Error.txt", "w", stderr);
#endif
FASTIO;


      test(){


            int n;
            cin>>n;

            int arr[n];

            loop(i,0,n){

                  cin>>arr[i];
            }

            bool ok=false;
            int cnt=0;

            for(int i=0;i<n;i++){


                  cnt+=1;

                  if(arr[i]<=cnt){

                        ok=true;
                        break;
                  }

            }

            if(ok){

                  print("YES")
            }
            else{
                  print("NO")
            }




      }



      return 0;


}


Comments

Submit
0 Comments
More Questions

1302. Deepest Leaves Sum
1209. Remove All Adjacent Duplicates in String II
994. Rotting Oranges
983. Minimum Cost For Tickets
973. K Closest Points to Origin
969. Pancake Sorting
967. Numbers With Same Consecutive Differences
957. Prison Cells After N Days
946. Validate Stack Sequences
921. Minimum Add to Make Parentheses Valid
881. Boats to Save People
497. Random Point in Non-overlapping Rectangles
528. Random Pick with Weight
470. Implement Rand10() Using Rand7()
866. Prime Palindrome
1516A - Tit for Tat
622. Design Circular Queue
814. Binary Tree Pruning
791. Custom Sort String
787. Cheapest Flights Within K Stops
779. K-th Symbol in Grammar
701. Insert into a Binary Search Tree
429. N-ary Tree Level Order Traversal
739. Daily Temperatures
647. Palindromic Substrings
583. Delete Operation for Two Strings
518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST